home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / alangsbs.zip / SHOWCHAR.ASM < prev    next >
Assembly Source File  |  1991-12-15  |  3KB  |  89 lines

  1. ;---------------------------------------------------------------
  2. ;                          SHOWCHAR.ASM
  3. ;       Demonstration of STOSW to disjoint areas of memory
  4. ;       through the display of an ASCII table direct to the
  5. ;       video refresh buffer
  6. ;
  7. ;                                      by Jeff Duntemann
  8. ;                                      MASM/TASM
  9. ;                                      Last update 12/14/91
  10. ;---------------------------------------------------------------
  11.  
  12. INCLUDE MYLIB.MAC               ; Load in screen control macro library
  13.  
  14. ;----------------------------|
  15. ;    BEGIN STACK SEGMENT     |
  16. ;----------------------------|
  17. MYSTACK    SEGMENT STACK        ; STACK word ensures loading of SS by DOS
  18.  
  19.            DB      64 DUP ('STACK!!!') ; This reserves 512 bytes for the stack
  20.  
  21. MYSTACK    ENDS
  22. ;----------------------------|
  23. ;     END STACK SEGMENT      |
  24. ;----------------------------|
  25.  
  26.  
  27. ;----------------------------|
  28. ;     BEGIN DATA SEGMENT     |
  29. ;----------------------------|
  30. MyData     SEGMENT
  31.  
  32. LRXY       DW      184FH ; 18H = 24D; 4FH = 79D; 0-based XY of LR screen corner
  33.  
  34. VidOrigin  DD      0B0000000H   ; Change to 0B0000000H if you have a mono CRT!
  35. CRLF       DB      0DH,0AH
  36.  
  37. ScrnWidth  EQU     80        ; Width of the screen in characters
  38. LineLen    EQU     64        ; Length of one line of the ASCII table
  39. LinesDown  EQU      4        ; Number of lines down to start ASCII table
  40.  
  41. MyData     ENDS
  42. ;----------------------------|
  43. ;      END DATA SEGMENT      |
  44. ;----------------------------|
  45.  
  46. ;----------------------------|
  47. ;     BEGIN CODE SEGMENT     |
  48. ;----------------------------|
  49.  
  50. MyProg     SEGMENT
  51.  
  52.            assume CS:MyProg,DS:MyData
  53. Main       PROC
  54.  
  55. Start:     ; This is where program execution begins:
  56.            mov    AX,MyData    ; Set up our own data segment address in DS
  57.            mov    DS,AX        ; Can't load segment reg. directly from memory
  58.  
  59.            Clear  VidOrigin,0720H,4000  ; Clear full video buffer to spaces
  60.  
  61.            les    DI,DWORD PTR VidOrigin   ; Put vid seg in ES & offset in DI
  62.            add    DI,ScrnWidth*LinesDown*2 ; Start table display down a ways
  63.            mov    CX,256      ; There are 256 chars in the ASCII set
  64.            mov    AX,0700H    ; Start with char 0, attribute 7
  65.  
  66. DoLine:    mov    BL,LineLen  ; Each line will consist of 64 characters
  67. DoChar:    stosw              ; Note that there's no REP prefix!
  68.            jcxz   AllDone     ; When the full set is printed, quit
  69.            inc    AL          ; Bump the character value in AL up by 1
  70.            dec    BL          ; Decrement the line counter by one
  71.            loopnz DoChar      ; Go back & do another char until BL goes to 0
  72.            add    DI,(ScrnWidth - LineLen)*2 ; Move DI to start of next line
  73.            jmp    DoLine      ; Start display of the next line
  74.  
  75. AllDone:   GotoXY 0,12        ; Move hardware cursor down below char. table
  76.            mov    AH,4CH      ; Terminate process DOS service
  77.            mov    AL,0        ; Pass this value back to ERRORLEVEL
  78.            int    21H         ; Control returns to DOS
  79.  
  80. Main       ENDP
  81.  
  82. MyProg     ENDS
  83.  
  84. ;----------------------------|
  85. ;      END CODE SEGMENT      |
  86. ;----------------------------|
  87.  
  88.            END Start    ; The procedure named Start becomes the main program
  89.